//
//  FirstViewController.swift
//  HZJNewClassUseByStoryBoard
//
//  Created by HZJ on 17/1/9.
//  Copyright © 2017年 HZJ. All rights reserved.
//

import UIKit

class FirstViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor.white
//        self.edgesForExtendedLayout = .None
        
        let lab = UILabel(frame: self.view.frame)
        lab.textAlignment = .center
        lab.text = "点击屏幕吧！！！"
        //MARK: weight：字体粗细，范围 -1 ~ 1
        lab.font = UIFont.systemFont(ofSize: 22, weight: UIFont.Weight(rawValue: 1))
//        lab.font = UIFont(name: "Helvetica-Bold", size: 22)
        view.addSubview(lab)
        
        setUpUI()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
        if true {
//            return
            let storyBoard = UIStoryboard(name: "Main", bundle: nil)
            let vc = storyBoard.instantiateViewController(withIdentifier: "HZJViewController") as! HZJViewController
//            let vc = HZJViewController()
            navigationController?.pushViewController(vc, animated: true)
        }
        
        if true {
            
        }
    }
    fileprivate func setUpUI(){
        if false {
//            addChildViewController(myVC)
            myVC.view.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height * 0.2)
            self.view.addSubview(myVC.view)
        }
        
        if true {
            //MARK: HZJButton虽未调用init(frame: CGRect)，但任然会调用init(frame: CGRect)，只是此时所传的frame为（0，0，0，0）
            view.addSubview(myBtn)
            myBtn.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
            myBtn.center = view.center
        }
    }
    
    fileprivate lazy var myVC:HZJViewController = HZJViewController()
    
    fileprivate lazy var myBtn:HZJButton = HZJButton()

}
